<template>
  <div class="citySelectWrap">
    <van-popup
      v-model="showCity"
      :close-on-click-overlay="false"
      position="bottom"
      get-container="body"
      :style="{ height: '50%' }"
    >
      <van-picker
        title="选择市"
        show-toolbar
        :default-index="index"
        :columns="columns"
        @confirm="onConfirm"
        @cancel="onCancel"
      />
    </van-popup>
  </div>
</template>
<script type="text/javascript">
import { getItem } from "../../util/storage.js";
export default {
  data() {
    return {
      showCity: true,
      index: 0,
      columns: [
        '太原市',
        '大同市',
        '阳泉市',
        '长治市',
        '晋城市',
        '朔州市',
        '晋中市',
        '运城市',
        '忻州市',
        '临汾市',
        '吕梁市',
      ],
    }
  },
  props: {
    arr: {
      type: Array,
      default: Array,
    },
  },
  // created() {
  //   var username = getItem("username");
   

  //   var city = "";
  //   let list = {
  //       ll01: "吕梁市",
  //       ty01: "太原市",
  //       dt01: "大同市",
  //       yq01: "阳泉市",
  //       cz01: "长治市",
  //       jc01: "晋城市",
  //       sz01: "朔州市",
  //       jz01: "晋中市",
  //       yc01: "运城市",
  //       xz01: "忻州市",
  //       lf01: "临汾市",
  //     };
     
  //     for (let key in list) {
  //       if (key == username) {
        
  //         this.columns=  this.columns.filter(it=>{
  //       return  it==list[key]
  //    })
        
  //       }
  //     }
    
  // },
  mounted() {
    this.columns.forEach((it, index) => {
      if (this.arr[0] == it) {
        this.index = index
      }
    })
  },
  watch: {},
  components: {},
  methods: {
    onCancel() {
      this.$emit('closeEmit')
    },
    onConfirm(value) {
      this.$emit('confirmEmit', value)
    },
  },
}
</script>
<style type="text/css" lang="less">
.citySelectWrap {
}
</style>
